const express = require('express')
const router = express.Router()
/**登录验证 */
const { jwtValidator } = require('../middleware/jsonwebtoken/index')
//操作的中间件
const vodController = require('../controller/vodController')
const videoController = require('../controller/videoController')
//验证中间件
const {createVideoValidator} = require('../middleware/validator/video')
router
//获取阿里云视频上传的各种凭证
.post('/getvod', jwtValidator(), vodController.getvod)
//创建视频
.post('/createvideo',jwtValidator(),createVideoValidator,videoController.createvideo)
//分页显示视频列表
.get('/videolist',jwtValidator(),videoController.videolist)
//获取视频详情(判断req.userinfo是否存在来判断是否登录)
.get('/video/:videoid',jwtValidator(false),videoController.video)
//添加视频评论
.post('/addcomment/:videoid',jwtValidator(),videoController.addcomment)
//获取评论列表
.get('/commentlist/:videoid',jwtValidator(false),videoController.commentlist)
//删除评论
.delete('/deletecomment/:videoid/:commentid',jwtValidator(),videoController.deletecomment)
//喜欢视频
.get('/like/:videoid',jwtValidator(),videoController.like)
//不喜欢视频
.get('/dislike/:videoid',jwtValidator(),videoController.dislike)
//喜欢视频列表
.get('/likelist',jwtValidator(),videoController.likelist)
//获取热门视频列表
.get('/tophots/:size',videoController.tophots)
module.exports = router